internal: define package variables for paths#20060
internal: define package variables for paths#20060tacerus wants to merge 1 commit intogoauthentik:mainfrom
Conversation
During distribution packaging, files are typically installed in standardized paths (for example, adhering to the FHS). Avoid the need for patching the source code to facilitate this by allowing the paths needed by the server to be overwritten at build time. The defaults are kept as they are to not affect existing behavior. Example usage (simplified): $ go build \ -ldflags '-X "goauthentik.io/internal/gounicorn.manageCmd=/usr/bin/ak-manage" -X "goauthentik.io/internal/gounicorn.gunicornCmd=/usr/bin/gunicorn" -X "goauthentik.io/internal/gounicorn.gunicornConf=/etc/authentik/gunicorn.conf.py" -X "goauthentik.io/internal/gounicorn.pidDir=/run/authentik" -X "goauthentik.io/web.staticDir=/usr/share/authentik/web/dist"' ./cmd/server Ideally, similar functionality would also exist for the various path references in the Python code. However, those require further consideration as there is no equivalent concept of build time options like there is in Go. Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20060 +/- ##
==========================================
- Coverage 93.25% 93.19% -0.07%
==========================================
Files 968 968
Lines 53438 53438
==========================================
- Hits 49836 49802 -34
- Misses 3602 3636 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
BeryJu
left a comment
There was a problem hiding this comment.
Looks good for the most part; if you dont mind me asking what's the idea behind adjusting these paths?
|
|
||
| func (g *GoUnicorn) initCmd() { | ||
| command := "./manage.py" | ||
| command := manageCmd |
There was a problem hiding this comment.
I dont think this is required for this, since manage.py is only used during development where you're probably running go run ./cmd/server
There was a problem hiding this comment.
Thanks for the pointer, I didn't realize it was overwritten after !config.Get().Debug. I think it might still be useful though if trying to debug against the system Python environment?
| args := []string{"dev_server"} | ||
| if !config.Get().Debug { | ||
| pidFile, err := os.CreateTemp("", "authentik-gunicorn.*.pid") | ||
| pidFile, err := os.CreateTemp(pidDir, "authentik-gunicorn.*.pid") |
There was a problem hiding this comment.
Might not be needed since that'll just use TMP by default
There was a problem hiding this comment.
That was actually the reason, because I try to avoid storing files in world-writable directories. Indeed it could be set using TMPDIR, but it's not ideal because it would still default to /tmp on most systems if not set.
Details
During distribution packaging, files are typically installed in standardized paths (for example, adhering to the FHS). Avoid the need for patching the source code to facilitate this by allowing the paths needed by the server to be overwritten at build time.
The defaults are kept as they are to not affect existing behavior.
Example usage (simplified):
Ideally, similar functionality would also exist for the various path references in the Python code. However, those require further consideration as there is no equivalent concept of build time options like there is in Go.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)If applicable
make docs)